/**
 * 弹幕设置系统类型定义
 */

// 字体大小选项
export type FontSize = 12 | 18 | 24 | 30

// 透明度选项 (百分比)
export type Opacity = 25 | 50 | 75 | 100

// 速度选项 (像素/秒)
export type Speed = 120 | 150 | 180 | 230

// 显示区域选项
export type DisplayArea = 'quarter' | 'half' | 'threequarter' | 'fullscreen'

// 弹幕密度选项
export type BarrageDensity = 'sparse' | 'normal' | 'dense'

// 弹幕模式选项
export type BarrageMode = 'scroll' | 'fixed' | 'colorful' | 'advanced'

// 字体颜色模式
export type FontColorMode = 'single' | 'colorful' | 'custom'

// 弹幕设置接口
export interface BarrageSettings {
  fontSize: FontSize
  opacity: Opacity
  speed: Speed
  avoidPerson: boolean
  displayArea: DisplayArea
  density: BarrageDensity
  mode: BarrageMode
  screenScale: boolean
  preventBlock: boolean
  barrageEnabled: boolean
}

// 默认设置
export const DEFAULT_BARRAGE_SETTINGS: BarrageSettings = {
  fontSize: 18,
  opacity: 100,
  speed: 120,
  avoidPerson: true,
  displayArea: 'fullscreen',
  density: 'normal',
  mode: 'scroll',
  screenScale: false,
  preventBlock: false,
  barrageEnabled: true
}

// 字体大小选项配置
export const FONT_SIZE_OPTIONS = [
  { value: 12 as FontSize, label: '小', description: '12px' },
  { value: 18 as FontSize, label: '中', description: '18px' },
  { value: 24 as FontSize, label: '大', description: '24px' },
  { value: 30 as FontSize, label: '特大', description: '30px' }
]

// 透明度选项配置
export const OPACITY_OPTIONS = [
  { value: 25 as Opacity, label: '25%' },
  { value: 50 as Opacity, label: '50%' },
  { value: 75 as Opacity, label: '75%' },
  { value: 100 as Opacity, label: '100%' }
]

// 速度选项配置
export const SPEED_OPTIONS = [
  { value: 120 as Speed, label: '慢', description: '120px/s' },
  { value: 150 as Speed, label: '中', description: '150px/s' },
  { value: 180 as Speed, label: '快', description: '180px/s' },
  { value: 230 as Speed, label: '极快', description: '230px/s' }
]

// 显示区域选项配置
export const DISPLAY_AREA_OPTIONS = [
  { 
    value: 'quarter' as DisplayArea, 
    label: '1/4区域', 
    description: '3条轨道',
    trackCount: 3 
  },
  { 
    value: 'half' as DisplayArea, 
    label: '2/4区域', 
    description: '6条轨道',
    trackCount: 6 
  },
  { 
    value: 'threequarter' as DisplayArea, 
    label: '3/4区域', 
    description: '9条轨道',
    trackCount: 9 
  },
  { 
    value: 'fullscreen' as DisplayArea, 
    label: '全屏', 
    description: '12条轨道',
    trackCount: 12 
  }
]

// 字体颜色选项配置
export const FONT_COLOR_OPTIONS = [
  { value: 'single' as FontColorMode, label: '单一颜色', description: '使用固定颜色' },
  { value: 'colorful' as FontColorMode, label: '彩色', description: '随机多彩颜色' },
  { value: 'custom' as FontColorMode, label: '自定义', description: '用户选择颜色' }
]

// 设置项变更事件
export interface SettingChangeEvent<T = any> {
  key: keyof BarrageSettings
  value: T
  previousValue: T
}

// 设置面板状态
export interface SettingsPanelState {
  isOpen: boolean
  position: {
    x: number
    y: number
  }
  animating: boolean
}

// 预设设置方案
export interface SettingPreset {
  name: string
  description: string
  settings: BarrageSettings
}

// 内置预设方案
export const PRESET_SETTINGS: SettingPreset[] = [
  {
    name: '默认',
    description: '推荐的默认设置',
    settings: DEFAULT_BARRAGE_SETTINGS
  },
  {
    name: '性能优先',
    description: '优化性能，减少资源占用',
    settings: {
      ...DEFAULT_BARRAGE_SETTINGS,
      fontSize: 12,
      opacity: 75,
      displayArea: 'quarter',
      barrageEnabled: true
    }
  },
  {
    name: '视觉优先',
    description: '最佳视觉效果',
    settings: {
      ...DEFAULT_BARRAGE_SETTINGS,
      fontSize: 24,
      opacity: 100,
      speed: 150,
      avoidPerson: true,
      displayArea: 'fullscreen',
      barrageEnabled: true
    }
  }
]
